package com.lyz.dataStructure.JianZhiOffer;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 22:23
 * @Description:
 **/

import java.util.ArrayList;
import java.util.Stack;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/6/15 22:23
 *@Description:
 **/
/*
输入一个链表，按链表值从尾到头的顺序返回一个ArrayList。
 */


public class Test6 {
    public ArrayList<Integer>print(ListNode listNode){
        Stack<Integer> stack = new Stack<>();
        while(listNode!=null){
            stack.push(listNode.val);
            listNode = listNode.next;
        }

        ArrayList<Integer> list = new ArrayList<>();
         while (!stack.isEmpty()){
             list.add(stack.pop());
        }
        return list;
    }
}
